home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Music / MIDI / MidiPlay / ARexx / Example3.rexx < prev    next >
OS/2 REXX Batch file  |  1995-08-23  |  1KB  |  52 lines

  1. /* This is an example ARexx script for use with MidiPlay.
  2.    Use the following parameter: FILETYPEREXX=ThisScript.rexx
  3.    When MidiPlay cannot load a file, because it is not a MIDI file,  it
  4.    calls ThisScript. Argument consists of drive, path, file and extension
  5.    of the filename.
  6.  
  7.    This particular example tries to unarchive a file with extension lha
  8.    to a directory ram:t/rxmidi. If unarchiving is succesful, the first .MID
  9.    file is played by sending command 'FILE first.MID' to MidiPlay.
  10.  
  11. */
  12.  
  13. options results
  14.  
  15. parse arg Drive ',' Path ',' File ',' Extension .
  16.  
  17. address command
  18.  
  19. if ~show('L',"rexxsupport.library") then do
  20.   if ~addlib('rexxsupport.library',0,-30,0) then
  21.     exit 10
  22. end
  23.  
  24. if ~exists('t:rxmidi') then
  25.   'makedir t:rxmidi'
  26.  
  27. if Path == "" then Path2 = Path
  28. else Path2 = Path || '/'
  29.  
  30. Whole = '"' || Drive || Path2 || File || '.' || Extension || '"'
  31.  
  32. "delete >nil: t:rxmidi/#?"
  33.  
  34. if Extension='lha' | Extension='LHA' then
  35.     'sys:archivers/lha >nil: -x0 -q e 'Whole' t:rxmidi/'
  36. else     do
  37.        say 'Not a MIDI file' Whole
  38.        RETURN
  39.     end
  40.  
  41. dir1=showdir('t:rxmidi/','f','@')
  42. dir1=insert(dir1,'@')
  43. dir2=upper(dir1)
  44.  
  45. position=index(dir2,'.MID')
  46. position3=lastpos('@',dir2,position)
  47. position2=index(dir2,'.MID',position)
  48. filenam=substr(dir2,position3+1,(position2-position3)+3)
  49.  
  50. address "MidiPlay_rexx"
  51. 'FILE t:rxmidi/'filenam
  52.